stop using read64 for doubles; fix .gpl heading/speed
authorparkrrrr <parkrrrr>
Fri, 22 Sep 2006 13:29:56 +0000 (13:29 +0000)
committerparkrrrr <parkrrrr>
Fri, 22 Sep 2006 13:29:56 +0000 (13:29 +0000)
14 files changed:
an1.c
axim_gpb.c
defs.h
delgpl.c
easygps.c
gbfile.c
gtm.c
mapsource.c
psp.c
saroute.c
tpg.c
tpo.c
util.c
vitosmt.c

diff --git a/an1.c b/an1.c
index 53b661138e50cbb675bdcd66e7c43c87a655e49f..c6483eb61da335e94b5f7363cefeef389efbb6ec 100644 (file)
--- a/an1.c
+++ b/an1.c
@@ -127,7 +127,7 @@ ReadDouble( FILE * f )
        double tmp = 0;
        double result = 0;
        fread(&tmp, sizeof(tmp),1,f);
-       le_read64(&result, &tmp );
+       result = le_read_double( &tmp );
        return result;
 }
 
@@ -135,7 +135,7 @@ static void
 WriteDouble(FILE * f, double d)
 {
        double tmp = 0;
-        le_read64( &tmp, (void *)&d );
+        le_write_double( &tmp, d );
        fwrite( &tmp, sizeof(tmp), 1, f );
 }
 
index 90fe552b50e7fa2ec48e7cd9b63c4734c9f06a0a..c3383a0854cd7c991695ac01a16e537cd15fb73b 100644 (file)
@@ -67,9 +67,8 @@ decode_buff(const char *buff, route_head *track)
        tm.tm_hour = le_read16((void *) (buff + 24));
        tm.tm_min = le_read16((void *)  (buff + 26));
        tm.tm_sec = le_read16((void *)  (buff + 28));
-       
-       le_read64(&lat, (void *)        (buff + 32));
-       le_read64(&lon, (void *)        (buff + 40));
+       lat = le_read_double( (void *)  (buff + 32));
+       lon = le_read_double( (void *)  (buff + 40));   
        spd = le_read32_float((void *)  (buff + 48));
        dir = le_read32_float((void *)  (buff + 52));
 
diff --git a/defs.h b/defs.h
index 7b0d04c1baa407690fe3bbda668a9dc24d68b19b..c79cf9087af5cd748dd4f17a17173225fb0c2750 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -777,6 +777,11 @@ void le_write32(void *pp, const unsigned i);
 double pdb_read_double(void *p);
 void pdb_write_double(void *pp, double d);
 
+double le_read_double(void *p);
+double be_read_double(void *p);
+void le_write_double(void *p, double d);
+void be_write_double(void *p, double d);
+
 /*
  * Prototypes for generic conversion routines (util.c).
  */
index a3c6cae40ea4e9e2931d74ea3d0df0db44403035..ed326ef619d131a8c86f95ea457703e4e87ec5ec 100644 (file)
--- a/delgpl.c
+++ b/delgpl.c
@@ -64,11 +64,15 @@ gpl_read(void)
 
        while (fread(&gp, sizeof(gp), 1, gplfile_in) > 0) {
                wpt_tmp = waypt_new();
-               le_read64(&wpt_tmp->latitude, &gp.lat);
-               le_read64(&wpt_tmp->longitude, &gp.lon);
-               le_read64(&alt_feet, &gp.alt);
+               wpt_tmp->latitude = le_read_double(&gp.lat);
+               wpt_tmp->longitude = le_read_double(&gp.lon);
+               alt_feet = le_read_double(&gp.alt);
                wpt_tmp->altitude = FEET_TO_METERS(alt_feet);
                wpt_tmp->creation_time = le_read32(&gp.tm);
+               
+               wpt_tmp->course = le_read_double(&gp.heading);
+               wpt_tmp->speed = le_read_double(&gp.speed);             
+               
                track_add_wpt(track_head, wpt_tmp);
        }
 }
@@ -98,12 +102,16 @@ gpl_trackpt(const waypoint *wpt)
        double alt_feet = METERS_TO_FEET(wpt->altitude);
        int status = 3;
        gpl_point_t gp;
+       double speed = wpt->speed;
+       double heading = wpt->course;
        
        memset(&gp, 0, sizeof(gp));
        le_write32(&gp.status, status);
-       le_read64(&gp.lat, &wpt->latitude);
-       le_read64(&gp.lon, &wpt->longitude);
-       le_read64(&gp.alt, &alt_feet);
+       le_write_double(&gp.lat, wpt->latitude);
+       le_write_double(&gp.lon, wpt->longitude);
+       le_write_double(&gp.alt, alt_feet );
+       le_write_double(&gp.speed, speed );
+       le_write_double(&gp.heading, heading );
        le_write32(&gp.tm, wpt->creation_time);
 
        fwrite(&gp, sizeof(gp), 1, gplfile_out);
index facfaf7c15b0d16f9ccbd405b4e586d0180db677..dd0269c916ea6c454882cad948aa99767c8d0f96 100644 (file)
--- a/easygps.c
+++ b/easygps.c
@@ -96,7 +96,6 @@ data_read(void)
        char ibuf[10];
        char bbuf[4096];
        char *bbufp;
-       double d;
        do {
                unsigned char tag;
                waypoint *wpt_tmp;
@@ -157,13 +156,11 @@ data_read(void)
                                break;
                        case 0x63:
                                fread(ibuf, 8, 1, file_in);
-                               le_read64(&d, ibuf);
-                               wpt_tmp->latitude = d;
+                               wpt_tmp->latitude = le_read_double(ibuf);
                                break;
                        case 0x64:
                                fread(ibuf, 8, 1, file_in);
-                               le_read64(&d, ibuf);
-                               wpt_tmp->longitude = d;
+                               wpt_tmp->longitude = le_read_double(ibuf);
                                break;
                        case 0x65:
                        case 0x66:
@@ -220,10 +217,10 @@ ez_disp(const waypoint *wpt)
                write_pstring(wpt->icon_descr);
        }
        fputc(0x63, file_out);
-       le_read64(tbuf, &wpt->latitude);
+       le_write_double(tbuf, wpt->latitude);
        fwrite(tbuf, 8, 1, file_out);
        fputc(0x64, file_out);
-       le_read64(tbuf, &wpt->longitude);
+       le_write_double(tbuf, wpt->longitude);
        fwrite(tbuf, 8, 1, file_out);
        if (wpt->notes) {
                fputc(5, file_out);
index 8a457f91792a4d2f29fa0f6859952064f55660b0..f4773a3c4e7879a2264b632e0ee1325c6757ba6f 100644 (file)
--- a/gbfile.c
+++ b/gbfile.c
@@ -477,12 +477,8 @@ double
 gbfgetdbl(gbfile *file)
 {
        char buf[8];
-       double result;
-       
        gbfread(buf, 1, sizeof(buf), file);
-       le_read64(&result, buf);
-
-       return result;
+       return le_read_double(buf);
 }
 
 float
@@ -618,8 +614,7 @@ int
 gbfputdbl(const double d, gbfile *file)
 {
        char buf[8];
-       
-       le_read64(buf, (char *)&d);
+       le_write_double(buf, d );
        return gbfwrite(buf, 1, sizeof(buf), file);
 }
 
diff --git a/gtm.c b/gtm.c
index 981b0178aa7ce2ac717215129e22eaa98cd8ac32..379eb29a919f4ecb4ab30ffe059ca182db2f1588 100644 (file)
--- a/gtm.c
+++ b/gtm.c
@@ -107,10 +107,8 @@ static double
 fread_double(FILE *fd)
 {
        char buf[8];
-       double d;
        fread(buf, 8, 1, fd);
-       le_read64(&d, buf);
-       return d;
+       return le_read_double(buf);
 }
 
 static char *
@@ -203,7 +201,7 @@ static void
 fwrite_double(FILE *fd, double val)
 {
        char buf[8];
-       le_read64(buf, &val);
+       le_write_double(buf,val);
        fwrite(buf, 8, 1, fd);
 }
 
index 08ab2f142ece5dfeb7ba2169498da721ac4cf6b8..01e486426dd81ccd39774da73cfeb45c3b60a0ce 100644 (file)
@@ -97,26 +97,20 @@ arglist_t mps_args[] = {
  * A wrapper to ensure the doubles we fwrite are in correct endianness.
  */
 
-void
-le_fwrite64(void *ptr, int sz, int ct, FILE *stream)
+static void
+le_fwrite_double(double d, FILE *stream)
 {
        unsigned char cbuf[8];
-
-       if ((sz != 8) || (ct != 1)) {
-               fatal(MYNAME ": Bad internal arguments to le_fwrite64.\n");
-       }
-
-       le_read64(cbuf, ptr);
+       le_write_double(cbuf,d);
        fwrite(cbuf, 8, 1, stream);
 }
 
-void
-le_fread64(void *ptr, int sz, int ct, FILE *stream)
+static double
+le_fread_double( FILE *stream)
 {
        unsigned char cbuf[8];
-
        fread(cbuf, 8, 1, stream);
-       le_read64(ptr, cbuf);
+       return le_read_double(cbuf);
 }
 
 static void 
@@ -536,22 +530,22 @@ mps_waypoint_r(FILE *mps_file, int mps_ver, waypoint **wpt, unsigned int *mpscla
        
        fread(tbuf, 1, 1, mps_file);                            /* altitude validity */
        if (tbuf[0] == 1) {
-               le_fread64(&mps_altitude,sizeof(mps_altitude),1,mps_file);
+               mps_altitude = le_fread_double(mps_file);
        }
        else {
                mps_altitude = unknown_alt;
-               le_fread64(tbuf,sizeof(mps_altitude),1, mps_file);
+               fseek( mps_file, 8, SEEK_CUR );
        }
 
        mps_readstr(mps_file, wptdesc, sizeof(wptdesc));
 
        fread(tbuf, 1, 1, mps_file);                            /* proximity validity */
        if (tbuf[0] == 1) {
-               le_fread64(&mps_proximity,sizeof(mps_proximity),1,mps_file);
+               mps_proximity = le_fread_double(mps_file);
        }
        else {
                mps_proximity = unknown_alt;
-               le_fread64(tbuf,sizeof(mps_proximity),1, mps_file);
+               fseek( mps_file, 8, SEEK_CUR );
        }
 
        fread(tbuf, 4, 1, mps_file);                                    /* display flag */
@@ -567,11 +561,11 @@ mps_waypoint_r(FILE *mps_file, int mps_ver, waypoint **wpt, unsigned int *mpscla
 
        fread(tbuf, 1, 1, mps_file);                                    /* depth validity */
        if (tbuf[0] == 1) {
-               le_fread64(&mps_depth,sizeof(mps_depth),1,mps_file);
+               mps_depth = le_fread_double( mps_file );
        }
        else {
                mps_depth = unknown_alt;
-               le_fread64(tbuf,sizeof(mps_depth),1, mps_file);
+               fseek( mps_file, 8, SEEK_CUR );
        }
 
        if ((mps_ver == 4) || (mps_ver == 5)) {
@@ -704,7 +698,7 @@ mps_waypoint_w(FILE *mps_file, int mps_ver, const waypoint *wpt, const int isRou
        else {
                hdr[0] = 1;
                fwrite(hdr, 1 , 1, mps_file);
-               le_fwrite64(&mps_altitude, 8 , 1, mps_file);
+               le_fwrite_double( mps_altitude, mps_file );
        }
        if (wpt->description) fputs(ascii_description, mps_file);
        fwrite(zbuf, 1, 1, mps_file);   /* NULL termination */
@@ -717,7 +711,7 @@ mps_waypoint_w(FILE *mps_file, int mps_ver, const waypoint *wpt, const int isRou
        else {
                hdr[0] = 1;
                fwrite(hdr, 1 , 1, mps_file);
-               le_fwrite64(&mps_proximity, 8 , 1, mps_file);
+               le_fwrite_double( mps_proximity, mps_file );
        }
 
        le_write32(&display, display);
@@ -739,7 +733,7 @@ mps_waypoint_w(FILE *mps_file, int mps_ver, const waypoint *wpt, const int isRou
        else {
                hdr[0] = 1;
                fwrite(hdr, 1 , 1, mps_file);
-               le_fwrite64(&mps_depth, 8 , 1, mps_file);
+               le_fwrite_double(mps_depth, mps_file);
        }
 
        fwrite(zbuf, 2, 1, mps_file);           /* unknown */
@@ -904,11 +898,11 @@ mps_route_r(FILE *mps_file, int mps_ver, route_head **rte)
 
                fread(tbuf, 1, 1, mps_file);                    /* altitude validity */
                if (tbuf[0] == 1) {
-                       le_fread64(&mps_altitude,sizeof(mps_altitude),1,mps_file);      /* max alt of the whole route */
+                       mps_altitude = le_fread_double(mps_file);
                }
                else {
                        mps_altitude = unknown_alt;
-                       le_fread64(tbuf,sizeof(mps_altitude),1, mps_file);
+                       fseek( mps_file, 8, SEEK_CUR );
                }
 
                fread(&lat, 4, 1, mps_file); 
@@ -918,11 +912,11 @@ mps_route_r(FILE *mps_file, int mps_ver, route_head **rte)
 
                fread(tbuf, 1, 1, mps_file);                    /* altitude validity */
                if (tbuf[0] == 1) {
-                       le_fread64(&mps_altitude,sizeof(mps_altitude),1,mps_file);      /* min alt of the whole route */
+                       mps_altitude = le_fread_double(mps_file);
                }
                else {
                        mps_altitude = unknown_alt;
-                       le_fread64(tbuf,sizeof(mps_altitude),1, mps_file);
+                       fseek( mps_file, 8, SEEK_CUR );
                }
        }
 
@@ -1000,11 +994,11 @@ mps_route_r(FILE *mps_file, int mps_ver, route_head **rte)
        
                fread(tbuf, 1, 1, mps_file);                    /* altitude validity */
                if (tbuf[0] == 1) {
-                       le_fread64(&mps_altitude,sizeof(mps_altitude),1,mps_file);
+                       mps_altitude = le_fread_double(mps_file);
                }
                else {
                        mps_altitude = unknown_alt;
-                       le_fread64(tbuf,sizeof(mps_altitude),1, mps_file);
+                       fseek( mps_file, 8, SEEK_CUR );
                }
 
                /* with MapSource routes, the real waypoint details are held as a separate waypoint, so copy from there
@@ -1048,11 +1042,11 @@ mps_route_r(FILE *mps_file, int mps_ver, route_head **rte)
                
                        fread(tbuf, 1, 1, mps_file);                    /* altitude validity */
                        if (tbuf[0] == 1) {
-                               le_fread64(&mps_altitude,sizeof(mps_altitude),1,mps_file);
+                               mps_altitude = le_fread_double( mps_file );
                        }
                        else {
                                mps_altitude = unknown_alt;
-                               le_fread64(tbuf,sizeof(mps_altitude),1, mps_file);
+                               fseek( mps_file, 8, SEEK_CUR );
                        }
                }
 
@@ -1260,7 +1254,7 @@ mps_routehdr_w(FILE *mps_file, int mps_ver, const route_head *rte)
                else {
                        hdr[0] = 1;
                        fwrite(hdr, 1 , 1, mps_file);
-                       le_fwrite64(&maxalt, 8 , 1, mps_file);
+                       le_fwrite_double(maxalt, mps_file);
                }
 
                lat = GPS_Math_Deg_To_Semi(minlat);
@@ -1279,7 +1273,7 @@ mps_routehdr_w(FILE *mps_file, int mps_ver, const route_head *rte)
                        hdr[0] = 1;
 
                        fwrite(hdr, 1 , 1, mps_file);
-                       le_fwrite64(&minalt, 8 , 1, mps_file);
+                       le_fwrite_double(minalt, mps_file);
                }
 
                le_write32(&rte_datapoints, rte_datapoints);
@@ -1345,7 +1339,7 @@ mps_routedatapoint_w(FILE *mps_file, int mps_ver, const waypoint *rtewpt)
                else {
                        hdr[0] = 1;
                        fwrite(hdr, 1 , 1, mps_file);
-                       le_fwrite64(&mps_altitude, 8 , 1, mps_file);
+                       le_fwrite_double(mps_altitude, mps_file );
                }
 
                /* output end point 2 */
@@ -1364,7 +1358,7 @@ mps_routedatapoint_w(FILE *mps_file, int mps_ver, const waypoint *rtewpt)
                else {
                        hdr[0] = 1;
                        fwrite(hdr, 1 , 1, mps_file);
-                       le_fwrite64(&mps_altitude, 8 , 1, mps_file);
+                       le_fwrite_double(mps_altitude, mps_file);
                }
 
                if (rtewpt->latitude > prevRouteWpt->latitude) {
@@ -1409,7 +1403,7 @@ mps_routedatapoint_w(FILE *mps_file, int mps_ver, const waypoint *rtewpt)
                else {
                        hdr[0] = 1;
                        fwrite(hdr, 1 , 1, mps_file);
-                       le_fwrite64(&maxalt, 8 , 1, mps_file);
+                       le_fwrite_double(maxalt, mps_file);
                }
 
                /* output min coords of the link */
@@ -1425,7 +1419,7 @@ mps_routedatapoint_w(FILE *mps_file, int mps_ver, const waypoint *rtewpt)
                else {
                        hdr[0] = 1;
                        fwrite(hdr, 1 , 1, mps_file);
-                       le_fwrite64(&minalt, 8 , 1, mps_file);
+                       le_fwrite_double(minalt, mps_file );
                }
 
        }
@@ -1560,11 +1554,11 @@ mps_track_r(FILE *mps_file, int mps_ver, route_head **trk)
        
                fread(tbuf, 1, 1, mps_file);                    /* altitude validity */
                if (tbuf[0] == 1) {
-                       le_fread64(&mps_altitude,sizeof(mps_altitude),1,mps_file);
+                       mps_altitude = le_fread_double( mps_file );
                }
                else {
                        mps_altitude = unknown_alt;
-                       le_fread64(tbuf,sizeof(mps_altitude),1, mps_file);
+                       fseek( mps_file, 8, SEEK_CUR );
                }
 
                fread(tbuf, 1, 1, mps_file);                    /* date/time validity */
@@ -1577,11 +1571,11 @@ mps_track_r(FILE *mps_file, int mps_ver, route_head **trk)
 
                fread(tbuf, 1, 1, mps_file);                    /* depth validity */
                if (tbuf[0] == 1) {
-                       le_fread64(&mps_depth,sizeof(mps_depth),1,mps_file);
+                       mps_depth = le_fread_double(mps_file );
                }
                else {
                        mps_depth = unknown_alt;
-                       le_fread64(tbuf,sizeof(mps_depth),1, mps_file);
+                       fseek( mps_file, 8, SEEK_CUR );
                }
 
                thisWaypoint = waypt_new();
@@ -1706,7 +1700,7 @@ mps_trackdatapoint_w(FILE *mps_file, int mps_ver, const waypoint *wpt)
        else {
                hdr[0] = 1;
                fwrite(hdr, 1 , 1, mps_file);
-               le_fwrite64(&mps_altitude, 8 , 1, mps_file);
+               le_fwrite_double(mps_altitude, mps_file);
        }
 
        if (t > 0) {                                    /* a valid time is assumed to > 0 */
@@ -1725,7 +1719,7 @@ mps_trackdatapoint_w(FILE *mps_file, int mps_ver, const waypoint *wpt)
        else {
                hdr[0] = 1;
                fwrite(hdr, 1 , 1, mps_file);
-               le_fwrite64(&mps_depth, 8 , 1, mps_file);
+               le_fwrite_double(mps_depth, mps_file );
        }
 }
 
diff --git a/psp.c b/psp.c
index 76298718ea07ab9b272f4bea014ed069c2a26bc7..3970faaafb50bffb6459cca8ac733487f36d2b2b 100644 (file)
--- a/psp.c
+++ b/psp.c
@@ -53,20 +53,15 @@ static double
 psp_fread_double(FILE *fp)
 {
        unsigned char buf[8];
-       unsigned char sbuf[8];
-
        psp_fread(buf, 1, 8, fp);
-       le_read64(sbuf, buf);
-       return *(double *) sbuf;
+       return le_read_double(buf);
 }
 
 static void
 psp_fwrite_double(double x, FILE *fp)
 {
-       unsigned char *cptr = (unsigned char *)&x;
        unsigned char cbuf[8];
-
-       le_read64(cbuf, cptr);
+       le_write_double(cbuf,x);
        fwrite(cbuf, 8, 1, fp);
 }
 
index 925f42c1124401253e91ee8ae25fbb943b1d92d4..cd9648cf6bb9fb91fa8ffad273be3f6ca894f3d0 100644 (file)
--- a/saroute.c
+++ b/saroute.c
@@ -323,7 +323,7 @@ my_read(void)
                        }
                        
                        if ( timesynth ) {
-                               le_read64( &seglen, 
+                               seglen = le_read_double(
                                           record + 2 + stringlen + 0x08 );
                                starttime = le_read32((unsigned long *)
                                        (record + 2 + stringlen + 0x30 ));
diff --git a/tpg.c b/tpg.c
index f1f7715c9869476b8cfca4404b490561263d6ad0..122fa6488062c9a0b3861e21f6109f63093ede3c 100644 (file)
--- a/tpg.c
+++ b/tpg.c
@@ -65,20 +65,15 @@ static double
 tpg_fread_double(FILE *fp)
 {
        unsigned char buf[8];
-       unsigned char sbuf[8];
-
        tpg_fread(buf, 1, 8, fp);
-       le_read64(sbuf, buf);
-       return *(double *)sbuf;
+       return le_read_double(buf);
 }
 
 static void
 tpg_fwrite_double(double x, FILE *fp)
 {
-       unsigned char *cptr = (unsigned char *)&x;
        unsigned char cbuf[8];
-
-       le_read64(cbuf, cptr);
+       le_write_double(cbuf,x);
        fwrite(cbuf, 8, 1, fp);
 }
 
diff --git a/tpo.c b/tpo.c
index 8a3fed2b35b54cfa6400256ca2daf10dbaeb6835..0e3c1a22a989f00a6d2d677adee1c30272cf9d63 100644 (file)
--- a/tpo.c
+++ b/tpo.c
@@ -145,20 +145,15 @@ static double
 tpo_fread_double(FILE *fp)
 {
        unsigned char buf[8];
-       unsigned char sbuf[8];
-
        tpo_fread(buf, 1, 8, fp);
-       le_read64(sbuf, buf);
-       return *(double *)sbuf;
+       return le_read_double(buf);
 }
 
 static void
 tpo_fwrite_double(double x, FILE *fp)
 {
-       unsigned char *cptr = (unsigned char *)&x;
        unsigned char cbuf[8];
-
-       le_read64(cbuf, cptr);
+       le_write_double(cbuf,x);
        fwrite(cbuf, 8, 1, fp);
 }
 
diff --git a/util.c b/util.c
index 282ed20c25549a9ebf2c63f057715a242889e912..0a0356d7c6d41ce98e3d9445cbe30e5f67051a79 100644 (file)
--- a/util.c
+++ b/util.c
@@ -813,38 +813,65 @@ static int doswap()
 }
 
 double
-pdb_read_double(void* ptr)
+endian_read_double(void* ptr, int read_le)
 {
   double ret;
   char r[8];
+  void *p;
   int i;
   doswap(); /* make sure i_am_little_endian is initialized */
-  for (i = 0; i < 8; i++)
-  {
-       int j = (i_am_little_endian)?(7-i):i;
-       r[i] = ((char*)ptr)[j];
+  if ( i_am_little_endian == read_le ) {
+         p = ptr;
+  }
+  else {
+         for (i = 0; i < 8; i++)
+         {
+               r[i] = ((char*)ptr)[7-i];
+         }
+         p = r;
   }
-  memcpy(&ret, r, 8);
+  
+  memcpy(&ret, p, 8);
   return ret;
 }
 
 void
-pdb_write_double(void* ptr, double d)
+endian_write_double(void* ptr, double d, int write_le)
 {
-  char r[8];
+  char *r = (char *)(void *)&d;
   int i;
   char *optr = ptr;
 
-  memcpy(r, &d, 8);
   doswap(); /* make sure i_am_little_endian is initialized */
-  for (i = 0; i < 8; i++)
-  {
-       int j = (i_am_little_endian)?(7-i):i;
-       *optr++ = r[j];
+  if ( i_am_little_endian == write_le ) {
+         memcpy( ptr, &d, 8);
+  }
+  else {
+         for (i = 0; i < 8; i++)
+         {
+               *optr++ = r[7-i];
+         }
   }
-  return;
 }
 
+double
+pdb_read_double( void *ptr ) {return endian_read_double(ptr, 0);}
+
+double 
+le_read_double( void *ptr ) {return endian_read_double(ptr,1);}
+
+double 
+be_read_double( void *ptr ) {return endian_read_double(ptr,0);}
+
+void
+pdb_write_double( void *ptr, double d ) {endian_write_double(ptr,d,0);}
+
+void
+le_write_double( void *ptr, double d ) {endian_write_double(ptr,d,1);}
+
+void 
+be_write_double( void *ptr, double d ) {endian_write_double(ptr,d,0);}
+
 /* Magellan and PCX formats use this DDMM.mm format */
 double ddmm2degrees(double pcx_val) {
        double minutes;
index 3ca048651ba3eadf31efa00ceaa078861aedcfc4..4a9bedf64efe0aaae6fe7c743bbf1f519e11694b 100644 (file)
--- a/vitosmt.c
+++ b/vitosmt.c
@@ -53,11 +53,8 @@ static double
 ReadDouble(FILE * f)
 {
        unsigned char buffer[8] = "\0\0\0\0\0\0\0\0";
-       double result=0;
-
        fread(buffer, sizeof (buffer), 1, f);
-       le_read64(&result,buffer);
-       return result;
+       return le_read_double(buffer );
 }
 
 
@@ -75,11 +72,8 @@ static void
 WriteDouble(void* ptr, double d)
 {
   unsigned char result[8]="\0\0\0\0\0\0\0\0";
-
-  le_read64(result, &d);
+  le_write_double(result,d);
   memcpy(ptr, result, 8);
-
-  return;
 }